<?php
$section = "about_us";

$titre = _LB_ABOUT_US;
$smarty->assign('titre', $titre);

$id = Request::getIntNumber('id');

$act = Request::getIntNumber('act');
$backlink = Session::getbacklink($section,"list/?");

$aboutUs = new About_Us();


if ($id > 0 && $aboutUs->get($id) == false)
	redirect($backlink);


if ($act == ACT_VALID_EDIT)
{
    $aboutUs->TITLE = Request::get("TITLE");
    $aboutUs->SHORT_DESCRIPTION = Request::get("SHORT_DESCRIPTION");
    $aboutUs->DESCRIPTION = Request::get("DESCRIPTION");
    $aboutUs->POS = Request::getIntNumber("POS");
    $aboutUs->STATUS = Request::getIntNumber("STATUS");
    if($aboutUs->TITLE == ""){
        $error_msg->add(_MSG_TITLE_IS_EMPTY);
    }
    if (!sizeof($error_msg->errors))
    {
        $aboutUs->store();
        redirect($backlink);
    }
}
elseif ($act== ACT_DELETE)
{
	$aboutUs->delete();

	redirect($backlink);
}
else if($act == ACT_DISABLE){
    $aboutUs->STATUS = 0;
    $aboutUs->update();
    redirect($backlink);
}
else if($act == ACT_ENABLE){
    $aboutUs->STATUS = 1;
    $aboutUs->update();
    redirect($backlink);
}

// create head name
if ($aboutUs->ID){
    $head_name = _LB_EDIT_PAGE;
    $head_name_box = _LB_ABOUT_US;
}
else{
    $head_name = _LB_ADD_NEW_PAGE;
    $head_name_box = _LB_ABOUT_US;
}

// create Cfer
$cfer = new Cfer(array(
    _LB_ACCUEIL => Utils::getHomeLink(),
    _LB_USER_MANAGEMENT => APPLICATION_URL . '/about_us/list/?',
    $head_name => Utils::getCurrentLink()
));

$smarty->assign("aboutUs", $aboutUs);
$smarty->assign("act", $act);
$smarty->assign("backlink",$backlink);
$smarty->assign("cfer",$cfer);
$smarty->assign("lb_head",$head_name);
$smarty->assign("lb_head_box",$head_name_box);
$smarty->display("about_us_form.html");